<?php
//require section
require_once dirname(__FILE__) . '/shared/config/config.php';
require_once DOCUMENT_ROOT . DIR_INCLUDE . 'check_session.php';
require_once DOCUMENT_ROOT . DIR_INCLUDE . 'check_inside_booking.php';
require_once DOCUMENT_ROOT . DIR_SHARED_API . 'api_combos.php';
require_once DOCUMENT_ROOT . DIR_SHARED_LIBRARIES . 'lib_redirect.php';
$title = 'Choose Combo';


$_SESSION['book_info']['coupon_id'] = 0;
$_SESSION['book_info']['coupon_code'] = "";

?>

<!DOCTYPE html>
<html>
    <head>
        <?php
        require_once DOCUMENT_ROOT . DIR_INCLUDE . 'head.php';
        ?>
        <script>
             $(document).ready(function() {
                $('#txt_combo_quantity').attr('disabled','disabled');
                $('input[name="ddl_combo"]').attr('disabled','disabled');
                $("#cb_enable_combo").val("on");
                
                $( "#togg" ).on( "click", function() {
                    var enabled = $("#cb_enable_combo").val();
                    if (enabled === "on") {
                        $('#txt_combo_quantity').removeAttr('disabled');
                        $('input[name="ddl_combo"]').removeAttr('disabled');
                        $("#cb_enable_combo").val("off");
                    } else {
                        $('#txt_combo_quantity').attr('disabled','disabled');
                        $('input[name="ddl_combo"]').attr('disabled','disabled');
                        $("#cb_enable_combo").val("on");
                    }
                });
            });
        </script>
    </head>
    <body>
        <div class="ts-body-container">
            <div class="ts-wrapper">
                <div class="padding-top-large row">
                    <?php
                    require_once DOCUMENT_ROOT . DIR_INCLUDE . 'header.php';
                    ?>
                </div>
                <div class="ui grid">
                    <div class="row">
                        <div class="column">
                            <!-- Step -->
                            <div id='booking_step' class="ui four steps margin-top-normal">
                                <div class="ui disabled step">
                                    Choose Cinema & Time Start
                                </div>
                                <div class="ui disabled step">
                                    Choose Seats
                                </div>
                                <div class="ui active step">
                                    Choose Combo
                                </div>
                                <div class="ui disabled step">
                                    Coupon Code & Finish
                                </div>
                            </div>
                            <!-- End Step -->

                            <h1>Choose Combo</h1>

                            <form id="form_choose_combo" action="coupon_finish.php" method="post" name="form_choose_combo">
                                <div class="ui orange segment">
                                    <table style="width: 50%; margin-left: auto; margin-right: auto;">
                                        <tr>
                                            <td style="text-align: right; padding-right: 5px; font-weight: bold;">Enable Combo:</td>
                                            <td style="margin-left: 10px;" class="ui left icon input">
                                                <div class="inline field">
                                                    <div id="togg" class="ui toggle checkbox">
                                                        <input id="cb_enable_combo" name="cb_enable_combo" type="checkbox" >
                                                        <label for="a"><span style="color: #D95C5C;">Disabled</span> / <span style="color: #A1CF64;">Enabled</span></label>
                                                    </div>
                                                </div>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="text-align: right; padding: 15px 0; font-weight: bold;">Select Combo:</td>
                                            <td style="margin: 15px 0 15px 10px;" class="ui left icon input">
                                                <?php
                                                $list = api_combos::get_all_combos();
                                                $item_id = 0;
                                                $item_name = "-";
                                                if (!empty($list) && count($list) > 0) {
                                                    $item_id = $list[0]['id'];
                                                    $item_name = $list[0]['name'];
                                                }
                                                ?>
                                                <div class="ui orange selection dropdown">
                                                    <input name="ddl_combo" type="hidden" value="<?php echo $item_id; ?>">
                                                    <div class="default text"><?php echo $item_name; ?></div>
                                                    <i class="dropdown icon"></i>
                                                    <div class="menu">
                                                        <?php
                                                        foreach ($list as $item) {
                                                        ?>
                                                        <div class="item" data-value="<?php echo $item['id']; ?>"><?php echo $item['name']; ?></div>
                                                        <?php
                                                        }?>
                                                    </div>
                                                </div>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="text-align: right; padding-right: 5px; font-weight: bold;">Combo Quantity:</td>
                                            <td style="margin-left: 10px;" class="ui left icon input">
                                                <input name="txt_combo_quantity" id="txt_combo_quantity" type="text" placeholder="0">
                                                <i class="inverted list icon"></i>
                                            </td>
                                        </tr>
                                    </table>
                                </div>
                                <div class="ui orange segment">
                                    <div class="ts-center">
                                        <div class="ui buttons">
                                            <!--<div class="ui green button">Back</div>-->
                                            <a href="seat.php#booking_step" class="ui purple button">Back</a>
                                            <div class="or"></div>
                                            <!--<div class="ui orange button">Next</div>-->
                                            <div onclick="submit_choose_combo();" class="ui orange button">Next</div>
                                        </div>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <?php
                    require_once DOCUMENT_ROOT . DIR_INCLUDE . 'footer.php';
                    ?>
                </div>
            </div>
        </div>
    </body>
</html>